package cn.st4rlight.util.check;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author st4rlight <st4rlight@163.com>
 * Created on 2025-05-03
 */
@Data
@AllArgsConstructor
public class DataCheckResult<T> {

    // 返回数据
    private T returnData;

    // 校验结果
    private SimpleCheckResult checkResult;


    public boolean hasPassCheck() {
        return checkResult.hasPassCheck();
    }

    public static <T> DataCheckResult<T> pass(T returnData) {
        return new DataCheckResult<>(returnData, SimpleCheckResult.pass());
    }

    public static <T> DataCheckResult<T> pass(String passReason) {
        return new DataCheckResult<>(null, SimpleCheckResult.pass(passReason));
    }

    public static <T> DataCheckResult<T> pass(T returnData, String passReason) {
        return new DataCheckResult<>(returnData, SimpleCheckResult.pass(passReason));
    }

    public static <T> DataCheckResult<T> reject(T returnData) {
        return new DataCheckResult<>(returnData, SimpleCheckResult.reject());
    }

    public static <T> DataCheckResult<T> reject(String rejectReason) {
        return new DataCheckResult<>(null, SimpleCheckResult.reject(rejectReason));
    }

    public static <T> DataCheckResult<T> reject(T returnData, String rejectReason) {
        return new DataCheckResult<>(returnData, SimpleCheckResult.reject(rejectReason));
    }
}
